//
//  ComposeView.m
//  OC-微博
//
//  Created by Apple on 15/11/16.
//  Copyright © 2015年 Apple. All rights reserved.
//

#import "ComposeView.h"
@interface ComposeView()
// 文本视图
//@property (nonatomic, strong) UITextView *textView;
// 工具条
@property (nonatomic, strong) UIToolbar *toolbar;
@end
@implementation ComposeView
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}
#pragma mark /*******************  设置界面  *******************/
- (void)setupUI {
    // 1. 设置背景颜色
    self.backgroundColor = [UIColor whiteColor];
    //2.添加控件
    [self prepareToolbar];
    [self prepareTextView];
}
#pragma mark /*******************  准备工具条  *******************/
- (void)prepareToolbar {
    [self addSubview:self.toolbar];
    self.toolbar.backgroundColor = [[UIColor alloc]initWithWhite:0.8 alpha:1.0];
    [self.toolbar makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.bottom);
        make.left.right.equalTo(self);
        make.height.equalTo(44);
    }];


}
#pragma mark /*******************  准备文本视图  *******************/
- (void)prepareTextView {
    [self addSubview:self.textView];
    [self.textView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top).offset(64);
        make.left.right.equalTo(self);
        make.bottom.equalTo(self.toolbar.top);
    }];
    self.textView.text = @"分享新鲜事。。。。";
}
#pragma mark /*******************   懒加载控件  *******************/
-(UIToolbar *)toolbar {
    
    if (_toolbar == nil) {
        _toolbar = [UIToolbar new];
    }
    return _toolbar;
}
-(UITextView *)textView {
    
    if (_textView == nil) {
        _textView = [UITextView new];
        _textView.font = [UIFont systemFontOfSize:18];
        _textView.textColor = [UIColor darkGrayColor];
        // 始终允许垂直滚动
        _textView.alwaysBounceVertical = YES;
        // 拖拽关闭键盘
        _textView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
        
        
    }
    return _textView;
}

@end
